/**
 * 
 */
package com.icss.ah.share.service;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.icss.ah.base.bean.EasyuiDataGridJson;

/**
 * @author qushuangshuang
 *
 */
@Service
@Transactional
public class UserShareService {

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	private final Logger errlog = Logger.getLogger(UserShareService.class);
	private final Logger infolog = Logger.getLogger(UserShareService.class);

	public EasyuiDataGridJson queryUserShareList(Map<String, Object> map) {
		EasyuiDataGridJson dataGridJson = new EasyuiDataGridJson();
		try {
			List<Map<String, Object>> rows = sqlSessionTemplate.selectList("UserShareMapper.queryUserShareList", map);
			Long total = sqlSessionTemplate.selectOne("UserShareMapper.queryUserShareListCount", map);
			dataGridJson.setRows(rows);
			dataGridJson.setTotal(total);
			infolog.info("UserShareService| queryUserShareList|para:" + map);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("UserShareService| queryUserShareList", e);
		}
		return dataGridJson;
	}

	public int auditUserShare(Map<String, Object> map) {
		int result = 0;
		try {
			sqlSessionTemplate.update("UserShareMapper.updateUserShare", map);
			infolog.info("UserShareMapper|updateUserShare" + map);
			result = 1;
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("UserShareMapper|updateUserShare", e);
		}
		return result;

	}

}
